{% extends 'cms/base.html' %}

{% block title %}板块管理{% endblock %}

{% block head %}
  <script src="{{ url_for('static',filename='cms/js/boards.js') }}"></script>
{% endblock %}

{% block page_title %}
  {{ self.title() }}
{% endblock %}

{% block main_content %}
  <div class="top-box">
      <a href="{{ url_for('cms.board_add') }}" class="btn btn-info btn-sm">添加新板块</a>
  </div>
  <table class="table table-bordered">
    <thead>
    <tr>
      <th>板块名称</th>
      <th>帖子数量</th>
      <th>创建时间</th>
      <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {% for board in boards %}
      <tr data-name="{{ board.name }}" data-id="{{ board.id }}">
        <td>{{ board.name }}</td>
        <td>{{ board.posts|length }}</td>
        <td>{{ board.create_time }}</td>
        <td>
            <a href="{{ url_for('cms.board_edit',board_id=board.id) }}" class="btn btn-info btn-sm">编辑</a>
            {% if board.is_active %}
          <button class="btn btn-danger btn-sm active-board-btn" data-active="1" data-board-id="{{ board.id }}">禁用</button>
            {% else %}
            <button class="btn btn-info btn-sm active-board-btn" data-active="0" data-board-id="{{ board.id }}">取消禁用</button>
            {% endif %}
        </td>
      </tr>
    {% endfor %}
    </tbody>
  </table>
    {{ pagination.links }}
{% endblock %}